package com.pls.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.pls.entity.Employee;

public class EmployeeMapper implements Mapper<Employee>
{

	public List<Employee> MapList(ResultSet rs) throws SQLException{
		List<Employee> employeeList = null;
		try {
			employeeList = new ArrayList<Employee>();
			Employee employee = null;
			while(rs.next()){
				employee = new Employee();
				employee.setEmailAddress(rs.getString("email_add"));
				employee.setFirstName(rs.getString("first_name"));
				employee.setLastName(rs.getString("last_name"));
				employee.setPositionCode(rs.getString("position_code"));
				employee.setId(rs.getInt("employee_id"));
				employeeList.add(employee);
			}
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return employeeList;
	}

	@Override
	public Employee Map(ResultSet rs) throws SQLException {
		Employee employee = null;
		try {
			while(rs.next()){
				employee = new Employee();
				employee.setEmailAddress(rs.getString("email_add"));
				employee.setFirstName(rs.getString("first_name"));
				employee.setLastName(rs.getString("last_name"));
				employee.setPositionCode(rs.getString("position_code"));
				employee.setId(rs.getInt("employee_id"));
				
				return employee;
			}
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return employee;
	}
	
	
	
}
